const express = require('express')

const app = express()

app.use('*', (req, res, next) => {
	res.setHeader('Access-Control-Allow-Origin', '*') // * | origin

	// TODO 2- 解决默认只支持 get post head
	res.setHeader('Access-Control-Allow-Methods', 'GET,POST,PATCH,DELETE,PUT')

	next()
})

app.patch('/info', function (req, res) {
	res.json({
		code: 200,
		type: 'patch',
	})
})

app.listen(8000, () => {
	console.log('http://localhost:8000')
})
